<template>
<view class="love">
		<div class="top">
			<div class="left">
				<img src="../../static/icon_cha.png" alt="">
				<span>已收藏12个餐宴</span>
			</div>
			<div class="right">
				<img src="../../static/icon_clear.png" alt="">
				<span>清空</span>
			</div>
		</div>
		{{$store.state.num}}
		<!-- <LoveItem :info="list" @del-love="handleCancel"></LoveItem> -->
		<!-- a4:使用 store中的数据 -->
		<LoveItem :info="$store.state.list" @del-love="handleCancel"></LoveItem>
			
		<!-- <div class="lo" v-for="(item,index) in list" :key="index">
			<img :src="item.pic" alt="">
			<div class="love_bt">
				<div class="love_bt_le">
					<h4>{{item.goodsname}}</h4>
					<p>￥{{item.price}}/份</p>
				</div>
				<div class="love_bt_ri">
					<img src="../../static/footer2.png" alt="">
					<p>取消收藏</p>
				</div>
			</div>
		</div> -->
		<!-- <div class="lo">
			<img src="../../static/goods4.png" alt="">
			<div class="love_bt">
				<div class="love_bt_le">
					<h4>盛夏海鲜家宴</h4>
					<p>￥4999/桌</p>
				</div>
				<div class="love_bt_ri">
					<img src="../../static/footer2.png" alt="">
					<p>取消收藏</p>
				</div>
			</div>
		</div> -->
		</div>
	</view>
</template>

<script>
	import LoveItem from "@/components/LoveItem"
	export default {
		data() {
			return {
				// list:[]
			};
		},
		components:{
			LoveItem
		},
		methods:{
			handleCancel(num){
				console.log("2.父组件接收到了子组件的数据",num);
				//根据下标，删除列表数据
				this.list.splice(num,1);
			}
		},
		created(){
			uni.request({
				url:' http://api.brqc.com.cn/shxmp/goodslist'
			})
			.then(res=>{
				console.log('心愿单',res)
				let result = res[1].data.data
				// this.list = result;
				//a2:保存数据到store
				this.$store.commit("SETLIST",result)
			})
		}
	}
</script>

<style lang="less" scoped>
.love{
	background-color: #fff;
	width: 100%;
	height: 100%;
	
	.top{
		border-top: 1px solid #ccc;
		display: flex;
		justify-content: space-between;
		padding: 30rpx;
		
		.left{
			display: flex;
			align-items: center;
			img{
				width: 30rpx;
				height: 30rpx;
			}
			span{
				font-size: 30rpx;
				margin-left: 20rpx;
			}
		}
		
		.right{
			display: flex;
			align-items: center;
			img{
				width: 30rpx;
				height: 30rpx;
			}
			span{
				font-size: 30rpx;
				margin-left: 10rpx;
				color: #ccc;
			}
		}
	}
	
	.bottom{
		padding: 0 30rpx ;
		
		.lo{
			display: flex;
			flex-direction: column;
			align-items: center;
			border-radius: 15rpx;
			box-shadow: 2rpx 2rpx 10rpx #ccc;
			margin-bottom: 30rpx;
			
			img{
				width: 100%;
				height: 420rpx;
				border-radius: 15rpx 15rpx 0 0;
			}
			
			.love_bt{
				width: 92%;
				display: flex;
				justify-content: space-between;
				padding: 20rpx;
				
				.love_bt_le{
					display: flex;
					flex-direction: column;
					justify-content: center;
					
					p{
						color: red;
						font-weight: 600;
					}
				}
				
				.love_bt_ri{
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					
					img{
						width: 50rpx;
						height: 50rpx;
					}
					
					p{
						color: #ccc;
						margin-top: 10rpx;
					}
				}
			}
		}
	}
}
</style>
